# Contributor: Mohammad Abdolirad <m.abdolirad@gmail.com>
# Maintainer: Mohammad Abdolirad <m.abdolirad@gmail.com>
pkgname=wait4x
pkgver=2.14.0
pkgrel=5
pkgdesc="Wait4X allows you to wait for a port or a service to enter the requested state"
url="https://wait4x.dev"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/atkrad/wait4x/archive/v$pkgver.tar.gz"
options="!check" # Wait4X doesn't provide tests

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	WAIT4X_COMMIT_REF_SLUG="v$pkgver" make build

	./dist/$pkgname completion bash > $pkgname.bash
	./dist/$pkgname completion fish > $pkgname.fish
	./dist/$pkgname completion zsh > $pkgname.zsh
}

package() {
	install -Dm755 "$builddir"/dist/$pkgname "$pkgdir"/usr/bin/$pkgname
	install -Dm644 "$builddir"/LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -Dm644 $pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
b42494e7b5b7cca21090c9baec3516a3f16b62381faa6473ceaafea3cd1af424e9fe935b405c18aa82a7bb6af70590a0f397aa41f2977104b7ac9a20fe388512  wait4x-2.14.0.tar.gz
"
